//跨域的问题
const fs = require('fs')
const http = require('http')
http.createServer((req,res)=>{
    const {url,method} = req
    if(url === '/' && method === 'GET'){
        fs.readFile('../static/index.html',(err,data)=>{
            if(err){
                res.writeHead(500,{
                    'Content-Type':'text/plain;charset=utf-8'
                })
                res.end('500 But Winter yyds')
                return
            }
            res.statusCode = 200
            res.setHeader('Content-Type','text/html')
            res.end(data)
        })
    }else{
        res.statusCode=400
        res.setHeader('Content-Type','text/plain;charset=utf-8')
        res.end('404 But Winter yyds')
    }
}).listen(3000,()=>{
    console.log('Server at 3000')
})